package com.gufe.system.common;

import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "openapi.system")
@Slf4j
public class OpenApiProperties {
    private String baseUrl;
    private String appId;
    private String appSecret;
    private int connectTimeout = 5000;
    private int readTimeout = 10000;

    // 添加PostConstruct方法在bean初始化后打印配置
    @PostConstruct
    public void init() {
        log.info("OpenApiProperties loaded:");
        log.info("baseUrl: {}", baseUrl);
        log.info("appId: {}", appId);
        log.info("appSecret: {}", appSecret != null ? "***" + appSecret.substring(Math.max(0, appSecret.length() - 4)) : "null");
        log.info("connectTimeout: {}", connectTimeout);
        log.info("readTimeout: {}", readTimeout);
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAppSecret() {
        return appSecret;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    public int getConnectTimeout() {
        return connectTimeout;
    }

    public void setConnectTimeout(int connectTimeout) {
        this.connectTimeout = connectTimeout;
    }

    public int getReadTimeout() {
        return readTimeout;
    }

    public void setReadTimeout(int readTimeout) {
        this.readTimeout = readTimeout;
    }
}